﻿using System.Collections.Generic;
using System;
using System.Runtime.Serialization;
/// <summary>
/// 숙박시설
/// 숙박비 : 10%
/// </summary>
public enum Lodging
{
    /// <summary>
    /// 아무것도 없음
    /// </summary>
    None=0,
    /// <summary>
    /// 여인숙: 구입비용 10000 
    /// </summary>
    Inn = 10000,
    /// <summary>
    /// 콘도 : 구입비용 20000 
    /// </summary>
    Condo = 20000,
    /// <summary>
    /// 호텔 : 구입비용 50000
    /// </summary>
    Hotel = 50000
}

/// <summary>
/// 아바타가 가는 모든곳
/// </summary>
[DataContract]
public abstract class Area
{
    protected static int fund;
    
    public static int Fund
    {
      get { return Area.fund; }
      set { Area.fund = value; }
    }
    
    const int MuindoQuorum = 3;
    [DataMember]
    public string Title
    {
        set;
        get;
    }
    public Area(string title)
    {
        Title = title;
    }
    public override bool Equals(object obj)
    {
        return Title == (obj as Area).Title;
    }
    public override int GetHashCode()
    {
        return Title.GetHashCode();
    }
    public abstract void Execute(User user);
}
/// <summary>
/// 아바타가 걸리면 조건에 의해 이벤트가 일어나는 곳.
/// </summary>
[DataContract]
public class EventZone : Area//아바타가 걸리면 이벤트를 일으키는 곳.
{
    public EventZone(string title)
        : base(title)
    {

    }
    public override void Execute(User user)
    {
        switch (Title)
        {
            case "출발지":
                user.Money += 100000;//만냥 보너스
                break;
            case "무인도":
                user.Muindo = 2;//두턴을 쉬게 합니다.
                break;
            case "우주정거장":
                user.Money -= 1000;
                //user.Position=user.CallbackArea
                break;
            case "기금입금":
                user.Money -= 1000;
                fund+=1000;
                //콜백으로 알림
                break;
            case "기금출금":
                user.Money += fund;
                fund=0;
                //콜백으로 알림
                break;
        }
    }
}
/// <summary>
/// 
/// </summary>
[DataContract]
public class Estate : Area
{
    public Estate(string title,
        int buyMoney
        )
        : base(title)
    {
        BuyMoney = buyMoney;
        SellMoney = (int)(BuyMoney * 0.6);
        Owner = null;
        Hotel = false;
        Condo = false;
        Inn = false;
    }
    [DataMember]
    public bool Hotel
    {
        set;
        get;
    }
    [DataMember]
    public bool Condo
    {
        set;
        get;
    }
    [DataMember]
    public bool Inn
    {
        set;
        get;
    }
    [DataMember]
    public User Owner
    {
        set;
        get;
    }
    [DataMember]
    public int BuyMoney
    {
        get;
        set;
    }
    [DataMember]
    public int SellMoney//팔때는 60%만 받음.
    {
        get;
        set;
    }
    
    public override void Execute(User user)
    {
        if (Owner == null)
        {
            return;
        }
        if (Owner.Id == user.Id)
        {
            return;
        }
        
    }
}
